import request from '@/api/request'

enum API {
	GETMESSAGELIST_URL = '/message/list', //获取所有聊天列表
	GETFRIENDCHATRECORDS_URL = '/message/friend', // 获取当前好友聊天消息记录
	GETGROUPCHATRECORDS_URL = '/message/group', // 获取当前群聊天记录消息

	MESSAGEREAD_URL = '/message/read', // 将消息变为已读
	VERIFYFILE_URL = '/verify/', // 校验文件hash接口
	UPLOADFILE_URL = '/chat/file/', // 文件上传接口
	MERGEFILE_URL = '/merge/' // 文件合并接口
}

// 获取所有聊天列表
export const reqGetMessageList = (userId: string) => {
	return request.post(API.GETMESSAGELIST_URL, { userId })
}

// 获取当前好友聊天消息记录
export const reqGetFriendChatRecordsList = (userId: string, friendId: string, pageNum: number) => {
	return request.post(API.GETFRIENDCHATRECORDS_URL, { userId, friendId, pageNum })
}

// 获取当前群聊天记录消息
export const reqGetGroupChatRecordsList = (userId: string, groupId: string, pageNum: number) => {
	return request.post(API.GETGROUPCHATRECORDS_URL, { userId, groupId, pageNum })
}

// 消息已读接口
export const reqMessageRead = (type: string, userId: string, id: string) => {
	return request.post(API.MESSAGEREAD_URL + '/' + type, { type, userId, id })
}

// 校验文件hash接口
export const reqVerifyHash = (data, type) => {
	return request.post(API.VERIFYFILE_URL + type, data)
}

// 文件上传接口
export const reqUploadFile = (data, type) => {
	return request.post(API.UPLOADFILE_URL + type, data)
}

// 文件合并接口
export const reqMergeFile = (data, type) => {
	return request.post(API.MERGEFILE_URL + type, data)
}
